/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.agi.myhome;

import java.io.Serializable;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;

/**
 *
 * @author Renato
 */
@Named
@ConversationScoped
public class ControladorEstoque implements Serializable {
    private boolean showEstoque;
    private boolean showCadastro;
    private boolean showEdicao;
    
    @Inject
    private Conversation conversation;
    
    public ControladorEstoque(){
        this.showEstoque=false;
    }
    
    private void resetarBooleanos(){
        this.showCadastro=false;
        this.showEdicao=false;
        this.showEstoque=false;
    }
    public void apresentarEstoque(){
        this.iniciarConversacao();
        resetarBooleanos();
        this.showEstoque=true;
    }
    
    
    public void apresentarEdicao(){
        this.iniciarConversacao();
        this.resetarBooleanos();
        this.showEdicao=true;
    }
    
    public void apresentarCadastro(){
        this.iniciarConversacao();
        this.resetarBooleanos();
        this.showCadastro=true;
    }
    public boolean isShowEstoque(){
        return showEstoque;
    }
    
    public boolean isShowCadastro(){
        return this.showCadastro;
    }
    
    public boolean isShowEdicao(){
        return this.showEdicao;
    }
    
    private void iniciarConversacao(){
        if(!conversation.isTransient()){
            conversation.end();
        }
        conversation.begin();
    }
    
    
}
